<?php 
global $dir_tpl, $tb_fix, $temp, $anyDB;  
function show_menu($num="",$go="",$rootid="",$catid=""){
    global $dir_tpl, $tb_fix, $temp, $anyDB;
    if($num==1){ // tour trong nuoc
        $sql = "select * from ".$tb_fix."_tour_menu where tme_root_id = 2 order by tme_order asc";
        $q = $anyDB->query($sql);
        $r = $anyDB->getAll();
        foreach($r as $k=>$v){
            $r[$k]['cat_url'] = convertText($v['tme_title']);
        }
    }
    if($num==2){ //tour nuoc ngoai
        $sql = "select * from ".$tb_fix."_tour_menu where tme_root_id = 1 and tme_parent_id = 0 order by tme_order asc";
        $q = $anyDB->query($sql);
        $r = $anyDB->getAll();
        foreach($r as $k=>$v){
            $tmeid = $v['tme_id'];
            $sql = "select * from ".$tb_fix."_tour_menu where tme_root_id = 1 and tme_parent_id = '$tmeid' order by tme_order asc";
            $q = $anyDB->query($sql);
            if($anyDB->numRows($q) > 0){
                    $rr = $anyDB->getAll();
                foreach($rr as $key=>$val){
                    $r[$k]['child'][] = $val;
                    foreach($r[$k]['child'] as $kk=>$vv){
                        $r[$k]['child'][$kk]['url'] = convertText($vv['tme_title']);
                    }
                }    
            }
        }
    }
    if($num==3){//khach san
        $sql = "select * from ".$tb_fix."_hotel_categorys where hca_parent_id = 0 order by hca_order asc";
        $q = $anyDB->query($sql);
        $r = $anyDB->getAll();
        foreach($r as $k=>$v){
            $hcaid = $v['hca_id'];
            $sql = "select * from ".$tb_fix."_hotel_categorys where hca_parent_id = '$hcaid' order by hca_order asc";
            $q = $anyDB->query($sql);
            if($anyDB->numRows($q) > 0){
                $rr = $anyDB->getAll();
                foreach($rr as $key=>$val){
                    $r[$k]['child'][] = $val;
                    foreach($r[$k]['child'] as $kk=>$vv){
                        $r[$k]['child'][$kk]['url'] = convertText($vv['hca_title']);
                    }
                }    
            }
        }
    }
    if($num==4){//dich vu
        $r['thuexe'] = "ChoTheuXe.html";
        $r['vida'] = "LamHoChieuVisa.html";
        $r['vemaybay'] = "DatVeMayBay.html";
        $r['huongdanviendl'] = "HuongDanVienDiLich.html";
    }
    return $r;
}
// tour trong nuoc
$tour_trongnuoc = show_menu(1);
$temp->assign("ttn",$tour_trongnuoc);
// tour trong nuoc
$tour_nuocngoai = show_menu(2);
$temp->assign("tnn",$tour_nuocngoai);
// tour trong nuoc
$khachsan = show_menu(3);
$temp->assign("hos",$khachsan);
// tour trong nuoc
$dichvu = show_menu(4);
$temp->assign("row",$dichvu);
//echo "<pre>";print_r($khachsan);die();
$temp->display("$dir_tpl/blocks/trong_danhmuc/index.mct"); 
?> 
